﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Import Namespace="FeaturesBlog.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Comments
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
        <% Html.RenderPartial("../Controls/BlogPostUserControl", ViewData["CurrentPost"]); %>
    <h2>Comments</h2>
    <% foreach (Comment c in (IEnumerable<Comment>)ViewData["Comments"])
        { %>
        <% Html.RenderPartial("../Controls/CommentUserControl", c); %>
    <% } %>
    <br />
    <div style="text-align:left">
        <input type="button" value="Create Comment" onclick="$('#createComment').fadeIn(300)" />
    </div>
    <div id="createComment" style="display:none">
        <% using (Html.BeginForm())
           {%>
        <%= Html.ValidationSummary(true)%>
        <fieldset>
            <legend>Comment</legend>
            <%if (!HttpContext.Current.User.Identity.IsAuthenticated)
              { %>
            <div class="editor-label">
                Name:
            </div>
            <div class="editor-field">
                <%= Html.TextBoxFor(model => ((Comment)model).UserDisplayName)%>
             </div>
             <%} %>
            <div class="editor-label">
                Body:
            </div>
            <div class="editor-field">
                <%= Html.TextAreaFor(model => ((Comment)model).CommentBody, new { style = "width:100%; height:100px" })%>
                <input type="hidden" value='<%= ((PostModel)ViewData["CurrentPost"]).BlogPost.PostId %>' name="PostId" id="PostId" />
            </div>
                <input type="submit" value="Create" onclick="return ($('#CommentBody').attr('value') != '')" />
                <input type="button" value="Cancel" onclick="$('#createComment').fadeOut(300)"/>
        </fieldset>

        <% } %>
    </div>
    <br /><br />
    <%= Html.ActionLink("back", "Index", "Home") %>
</asp:Content>
